#include "WidgetVariantGroup.h"
#include "ui_WidgetVariantGroup.h"
#include <iostream>

WidgetVariantGroup::WidgetVariantGroup(QWidget *parent) :
    WidgetVariant(parent),
    ui(new Ui::WidgetVariantGroup)
{
    ui->setupUi(this);
    QObject::connect(ui->buttonArrow, SIGNAL(clicked(bool)), 
                     this, SLOT(slotButtonClicked(bool)));

    ui->buttonArrow->setHidden(true);
    // ui->buttonArrow->setChecked(true);
}

WidgetVariantGroup::~WidgetVariantGroup()
{
    delete ui;
}

void WidgetVariantGroup::setGroupName(const QString& groupName)
{
    ui->labelName->setText(groupName);
}
   
void WidgetVariantGroup::addChildVariant(WidgetVariant* wv)
{
    m_childList.push_back(wv);
}
    
    
void WidgetVariantGroup::setChildHidden(bool ifHidden)
{
    for(int i = 0 ; i < m_childList.size(); i++)
    {
        m_childList[i]->setHidden(ifHidden);
    }
}

void WidgetVariantGroup::slotButtonClicked(bool checked)
{
    // std::cout<<"Debug WidgetVariantGroup::slotButtonClicked"<<std::endl;
    if(checked)
    {
        ui->buttonArrow->setText(QString::fromUtf8("\342\206\223"));
        setChildHidden(false);
    }
    else
    {
        ui->buttonArrow->setText(QString::fromUtf8("\342\206\222"));
        setChildHidden(true);
    }
}
